package com.zbkj.crmeb.merchant.admin.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.common.CommonPage;
import com.common.PageParamRequest;
import com.crmeb.core.common.CommonResult;
import com.zbkj.crmeb.store.dto.HomeStyleDTO;
import com.zbkj.crmeb.store.dto.HomeStyleTemplateDTO;
import com.zbkj.crmeb.store.model.HomeStyle;
import com.zbkj.crmeb.store.service.HomeStyleService;
import com.zbkj.crmeb.store.service.HomeStyleTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 首页模板
 * @Description: 
 *
 */
@RestController
@RequestMapping("api/admin/mer/home/style/template")
@Api(tags = "首页模板")
public class MerHomeStyleTemplateController extends AdminBaseController {
    @Autowired
    HomeStyleTemplateService homeStyleTemplateService;

    /**
     * 列表
     * @Description:
     * @author duyb
     * @param
     * @param @return
     * @return CommonResult<Object>
     * @throws
     */
    @ApiOperation(value = "列表")
    @GetMapping
    public CommonResult<List<HomeStyleTemplateDTO>> listEntity(HttpServletRequest request) {
        getMerId(request);
        return CommonResult.success(homeStyleTemplateService.listEntity());
    }

    /**
     * 通过模板类型查询
     * @Description:  
     * @author duyb
     * @param @param templateId 1: 综合商城类 2: 时尚消费类 3: 进口食品类 4: 酒水饮料类 5: 美妆日化类 6: 母婴教玩类 7: 数码家具类
     * @param @return
     * @return
     * @throws
     */
    @ApiOperation(value = "通过模板类型获取")
    @GetMapping("/{templateId}")
    public CommonResult<List<HomeStyleTemplateDTO>> getEntity(@ApiParam(value = "模板", required = true) @PathVariable("templateId") String templateId, HttpServletRequest request) {
        getMerId(request);
        return CommonResult.success(homeStyleTemplateService.listEntityByType(templateId));
    }

    /**
     * 新增
     * @Description:
     * @author duyb
     * @param @param homeStyleTemplate
     * @param @return
     * @return CommonResult<Object>
     * @throws
     */
    @ApiOperation(value = "新增或修改")
    @PostMapping("/saveorupdate")
    public CommonResult<Object> save(@RequestBody List<HomeStyleTemplateDTO> homeStyleTemplateDTOS, HttpServletRequest request) {
        getMerId(request);
        return CommonResult.success(homeStyleTemplateService.saveEntity(homeStyleTemplateDTOS));
    }
    
}
